package com.FH.permission.sys_role;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by acer on 2016/8/1.
 */

@Path("/sysrole")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class SysroleResource {
    @EJB
    private SysroleDAO sysroleDAO;

    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getSysroleInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size) {
        //添加分页查询
        //添加分页查询
        if (null == page || "".equals(page) || "0".equals(page)) {
            page = "1";    //默认从第0行开始查起
        }
        if (null == size || "".equals(size)) {
            size = "10";  //每页默认10条数据
        }
        return sysroleDAO.getSysroleInfo(search, page, size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addSysroleInfo(SysrolePullDTO dataDTO) {

        return sysroleDAO.addSysroleInfo(dataDTO);
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteSysroleInfo(SysrolePullDTO dataDTO) {
        return sysroleDAO.deleteSysroleInfo(dataDTO);
    }
}
